<!--
 * @Author: 莫卓才
 * @eMail: handsome.mo@foxmail.com
 * @Descripttion: 描述
 * @version: 1.0.0
 * @Date: 2020-02-20 18:16:13
 * @LastEditors: 莫卓才
 * @LastEditTime: 2020-06-12 19:30:14
 -->
<link href="../static/ueditor/themes/default/css/ueditor.min.css" type="text/css" rel="stylesheet">
<link href="../static/ueditor/themes/default/iframe.css" type="text/css" rel="stylesheet">

<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list"
  style="padding: 20px 30px 0 0;">
  <div class="layui-form-item">
    <label class="layui-form-label">标题</label>
    <div class="layui-input-inline" style="width: 450px;">
      <script type="text/html" template>
        <input type="text" name="title" value="{{ d.params.title || '' }}" lay-verify="required" placeholder="文章标题" autocomplete="off" class="layui-input">
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">所属分类</label>
    <div class="layui-input-inline">
      <script type="text/html" template lay-url="/api/news/getCategoryList" lay-done="layui.form.render('select');"
        lay-data="{'lang': layui.data('lang').lang}">
        <select name="category_id" id="category_id" required>
             <option value="">请选择</option>
              {{# layui.each(d.data,function(index,item){ }}
                <option value="{{ item.id }}" {{ item.name === d.params.category_name ? 'selected' : '' }}>{{ item.name }}</option>
              {{# }); }}
        </select>
       </script>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">来源</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <input type="text" name="source" value="{{ d.params.source || '' }}" placeholder="来源" autocomplete="off" class="layui-input">
      </script>
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">描述</label>
    <div class="layui-input-block" style="width: 450px;">
      <script type="text/html" template>
      <textarea name="description" placeholder="" class="layui-textarea">{{ d.params.description || '' }}</textarea>
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">缩略图</label>
    <div class="layui-input-inline" style="width: 345px;">
      <script type="text/html" template>
        <input type="text" name="thumb" id="thumb" value="{{ d.params.thumb || '' }}"  placeholder="请上传图片" autocomplete="off" class="layui-input" >
      </script>
    </div>
    <button style="float: left;" type="button" class="layui-btn" id="layuiadmin-upload-thumb">上传图片</button>
  </div>

  <script type="text/html" template>
    {{#
      if(d.params.thumb!=''&&d.params.thumb!=undefined&&d.params.category_id!=3){
    }}
      <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-inline" style="width: 345px;">
          <img src="{{ d.params.thumb }}" height="260">
        </div>
      </div>
    {{#
      }
    }}
  </script>

  <div class="layui-form-item">
    <label class="layui-form-label">内容</label>
    <div class="layui-input-inline" style="margin-bottom: 20px; width: 80%;">
      <script id="editor" type="text/plain"></script>
    </div>
    <!-- <div class="layui-form-item">
      <label class="layui-form-label">排序</label>
      <div class="layui-input-inline">
        <script type="text/html" template>
          <input type="text" name="sort" value="{{ d.params.sort || '' }}" placeholder="排序" autocomplete="off" class="layui-input">
        </script>
      </div>
    </div> -->

    <div class="layui-form-item">
      <label class="layui-form-label">状态</label>
      <div class="layui-input-inline">
        <script type="text/html" template>
        <input type="checkbox" lay-filter="status" name="status" lay-skin="switch" lay-text="显示|隐藏" {{ d.params.status != 0 ? 'checked' : '' }} >
      </script>
      </div>
    </div>

    <!-- <div class="layui-form-item">
      <label class="layui-form-label">时间</label>
      <div class="layui-input-inline">
        <script type="text/html" template>
          <input type="text" name="create_time" value="{{ d.params.create_time || '' }}" lay-verify="required" placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off" class="layui-input"  id="test5" onclick="createTime()">
        </script>
      </div>
    </div> -->

    <script type="text/html" template>
    <input type="hidden" name="id" value="{{ d.params.id || '' }}">
  </script>

    <script type="text/html" template>
    <input type="hidden" name="lang" value="{{ layui.data('lang').lang }}">
  </script>

    <div class="layui-form-item">
      <label class="layui-form-label"></label>
      <div class="layui-input-inline">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" value="确认" class="layui-btn">
      </div>
    </div>
  </div>
  <script type="text/javascript" src="/static/ueditor/ueditor.config.js"></script>
  <script type="text/javascript" src="/static/ueditor/ueditor.all.min.js"></script>
  <script type="text/javascript" src="/static/ueditor/index.js"></script>
  <script>
    layui.use(['admin', 'form', 'upload', 'laydate'], function () {
      var $ = layui.$
        , form = layui.form
        , upload = layui.upload;
      var laydate = layui.laydate;

      //日期时间选择器

      upload.render({
        elem: '#layuiadmin-upload-thumb'
        , url: '/api/uploads/thumb/column/news'
        , accept: 'file'
        , method: 'get'
        // ,acceptMime: 'image/*'
        , done: function (res) {
          $(this.item).prev("div").children("input").val(res.data.src)
          // console.log(res)
        }
      });

      form.on('radio(status)', function (data) {
        // console.log(data.elem); //得到radio原始DOM对象
        console.log(data.value); //被点击的radio的value值
      });

    })
    function createTime() {
      var laydate = layui.laydate;

      laydate.render({
        elem: '#test5'
        , type: 'datetime'
        , show: true
      });
    }
  </script>